import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _find from "lodash/find";
import _omit from "lodash/omit";
import _map from "lodash/map";
import _join from "lodash/join";
import _isUndefined from "lodash/isUndefined";
import _isNumber from "lodash/isNumber";
import _isEmpty from "lodash/isEmpty";
import _forEach from "lodash/forEach";
import _cloneDeep from "lodash/cloneDeep";
var _excluded = ["birthday", "startDateActive", "endDateActive"];

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _class, _class2, _class3;

/**
 * EditForm - 子账户管理 - 账号编辑表单
 * @date 2018/11/13

 */
import React from 'react';
import { Checkbox, Col, DatePicker, Form, Input, Modal, Row, Select, Switch, Tooltip, Icon } from 'antd';
import moment from 'moment';
import { Bind } from 'lodash-decorators';
import Lov from 'components/Lov';
import EditTable from 'components/EditTable';
import { Button as ButtonPermission } from 'components/Permission';
import { EMAIL, NOT_CHINA_PHONE, PHONE, CODE } from 'utils/regExp';
import intl from 'utils/intl';
import notification from 'utils/notification';
import { DEFAULT_DATE_FORMAT, FORM_COL_2_LAYOUT, MODAL_FORM_ITEM_LAYOUT } from 'utils/constants';
import { VERSION_IS_OP } from 'utils/config';
import { addItemsToPagination, createPagination, delItemsToPagination, getDateFormat, getEditTableData, tableScrollWidth } from 'utils/utils';
import { validatePasswordRule } from "../../../../utils/validator";
import RoleModal from "./RoleModal";
import styles from "../../index.less?modules";
/**
 * EditForm-编辑子账户信息
 * @reactProps {Function} fetchUserRoles 获取当前编辑用户已分配的角色
 * @reactProps {Object[]} dataSource 编辑用户已分配的角色
 * @reactProps {Object[]} LEVEL 资源层级的值集
 */

var EditForm = (_dec = Form.create({
  fieldNameProp: null
}), _dec2 = Bind(), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), _dec11 = Bind(), _dec12 = Bind(), _dec13 = Bind(), _dec14 = Bind(), _dec15 = Bind(), _dec16 = Bind(), _dec17 = Bind(), _dec18 = Bind(), _dec(_class = (_class2 = (_class3 = /*#__PURE__*/function (_React$Component) {
  _inherits(EditForm, _React$Component);

  var _super = _createSuper(EditForm);

  function EditForm(props) {
    var _this;

    _classCallCheck(this, EditForm);

    _this = _super.call(this, props);
    _this.state = {
      dataSource: [],
      // TODO: 什么时候重构
      oldDataSource: [],
      // 存储查询出来的数据 用来比较 以 排出没有更改的数据
      pagination: false,
      roleTableFetchLoading: false,
      level: [],
      selectedRowKeys: [],
      visible: false // 选择组织的框是否显示

    };
    var onRef = props.onRef;
    onRef(_assertThisInitialized(_this));
    _this.cancelDefaultParams = new Set();
    return _this;
  }

  _createClass(EditForm, [{
    key: "componentDidMount",
    value:
    /**
     * 将 hook 方法传递出去
     */
    function componentDidMount() {
      this.init();
    }
    /**
     * 初始化数据
     * 编辑 + 加载用户角色
     * 重置form表单
     */

  }, {
    key: "init",
    value: function init() {
      var _this$props = this.props,
          form = _this$props.form,
          isCreate = _this$props.isCreate;
      form.resetFields();
      this.cancelDefaultParams.clear();

      if (!isCreate) {
        // 在当前是编辑时
        this.handleRoleTableChange();
      }
    }
    /**
     * 检查 确认密码是否与密码一致
     * @param {String} rule
     * @param {String} value
     * @param {Function} callback
     */

  }, {
    key: "validatePasswordRepeat",
    value: function validatePasswordRepeat(rule, value, callback) {
      var form = this.props.form;

      if (value && value !== form.getFieldValue('password')) {
        callback(intl.get('ciam.subAccount.view.validation.passwordSame').d('确认密码必须与密码一致'));
      } else {
        callback();
      }
    }
    /**
     * 检查 有效日期至 大于 有效日期从
     * @param {String} rule
     * @param {String} value
     * @param {Function} callback
     */

  }, {
    key: "validateEndDateActive",
    value: function validateEndDateActive(rule, value, callback) {
      var form = this.props.form; // startDateActive 已经保证会有值

      if (value && !value.isAfter(form.getFieldValue('startDateActive'), 'day')) {
        callback(intl.get('ciam.subAccount.view.validation.timeRange').d('有效日期至必须大于有效日期从'));
      } else {
        callback();
      }
    }
    /**
     * 获取编辑完成的数据
     */

  }, {
    key: "getEditFormData",
    value: function getEditFormData() {
      var _this$props2 = this.props,
          form = _this$props2.form,
          initialValue = _this$props2.initialValue,
          isCreate = _this$props2.isCreate,
          organizationId = _this$props2.organizationId;
      var _this$state = this.state,
          dataSource = _this$state.dataSource,
          oldDataSource = _this$state.oldDataSource;
      var result = {};
      var saveData = {};
      var validateFields = ['realName', 'email', 'phone', 'startDateActive', 'endDateActive'];

      if (isCreate) {
        validateFields.push('password');
        validateFields.push('anotherPassword');
      } else {
        validateFields.push('enabled');
      }

      form.validateFields(function (err, values) {
        if (!err) {
          var excludeArray = [];
          var memberRoleList = [];
          var validatingDataSource = dataSource.filter(function (r) {
            return r._status === 'create' || r._status === 'update';
          });
          var validateDataSource = getEditTableData(validatingDataSource); // defaultRoleIds 不使用了, 使用 [ { roleId, tenantId, defaultFlag } ]

          var defaultRoles = [];

          _forEach(dataSource, function (record) {
            var r = _find(validateDataSource, function (or) {
              return or.id === record.id;
            });

            if (r) {
              // 是可以修改的数据
              var _startDateActive = r.startDateActive,
                  _endDateActive = r.endDateActive;

              var omitRecord = _omit(record, ['id', '_assignLevelValue', '_assignLevelValueMeaning', 'defaultRoleIdUpdate']);

              if (record.defaultRoleIdUpdate) {
                defaultRoles.push({
                  roleId: record.id,
                  tenantId: record.tenantId,
                  defaultFlag: record.defaultRole === false ? 0 : 1
                });
              }

              var newRecord = _objectSpread(_objectSpread({}, omitRecord), {}, {
                // 需要 _token 等字段
                roleId: record.id,
                assignLevel: record.assignLevel,
                assignLevelValue: record.assignLevelValue,
                memberType: record.memberType,
                sourceId: organizationId,
                sourceType: record.sourceType,
                startDateActive: _startDateActive && _startDateActive.format(DEFAULT_DATE_FORMAT),
                endDateActive: _endDateActive && _endDateActive.format(DEFAULT_DATE_FORMAT)
              }); // (VERSION_IS_OP && getCurrentOrganizationId() !== 0)
              // // 只有填写 分配层级 与 分配层级值 的角色才可以保存
              // switch (newRecord.assignLevel) {
              //   case 'org':
              //     newRecord.assignLevelValue = record.assignLevelValue;
              //     break;
              //   case 'organization':
              //   case 'site':
              //     // 如果是别人分配的 就不能修改
              //     newRecord.assignLevelValue = record.assignLevelValue || organizationId;
              //     break;
              //   default:
              //     break;
              // }
              // 由于这种写法 判断不了 哪些数据没有更新 所以全部保存


              if (!_isEmpty(newRecord.assignLevel) && _isNumber(newRecord.assignLevelValue)) {
                // 只有 当 旧数据修改后 才传给后端
                if (!oldDataSource.some(function (oldR) {
                  return oldR.id === record.id && record.assignLevel === oldR.assignLevel && record.assignLevelValue === oldR.assignLevelValue;
                }) || r._status === 'update' && record.startDateActive !== newRecord.startDateActive || record.endDateActive !== newRecord.endDateActive) {
                  memberRoleList.push(newRecord);
                }
              }

              excludeArray.push("assignLevel#".concat(record.id), "assignLevelValue#".concat(record.id));
            }
          });

          var _omit2 = _omit(values, excludeArray),
              birthday = _omit2.birthday,
              startDateActive = _omit2.startDateActive,
              endDateActive = _omit2.endDateActive,
              data = _objectWithoutProperties(_omit2, _excluded);

          result = _objectSpread(_objectSpread(_objectSpread({}, initialValue), data), {}, {
            startDateActive: startDateActive ? startDateActive.format(DEFAULT_DATE_FORMAT) : undefined,
            endDateActive: endDateActive ? endDateActive.format(DEFAULT_DATE_FORMAT) : undefined,
            birthday: birthday ? birthday.format(DEFAULT_DATE_FORMAT) : undefined,
            defaultRoles: defaultRoles,
            memberRoleList: memberRoleList,
            organizationId: organizationId
          });
          saveData = isCreate ? _objectSpread({
            userType: 'P'
          }, result) : result;
        }
      });
      return saveData;
    }
    /**
     * 新增角色模态框确认按钮点击
     */

  }, {
    key: "handleRoleAddSaveBtnClick",
    value: function handleRoleAddSaveBtnClick(roles) {
      var _this$props$isCreate = this.props.isCreate,
          isCreate = _this$props$isCreate === void 0 ? true : _this$props$isCreate;
      var _this$state2 = this.state,
          _this$state2$dataSour = _this$state2.dataSource,
          dataSource = _this$state2$dataSour === void 0 ? [] : _this$state2$dataSour,
          _this$state2$paginati = _this$state2.pagination,
          pagination = _this$state2$paginati === void 0 ? {} : _this$state2$paginati;
      this.setState({
        dataSource: [].concat(_toConsumableArray(_map(roles, function (r) {
          return _objectSpread(_objectSpread({}, _omit(r, ['assignLevel', 'assignLevelValue'])), {}, {
            // FIXME: 将角色之前的 层级信息 去掉
            memberType: 'user',
            // sourceType: r.level,
            // 租户级 可以分配的 肯定是 租户级的
            assignLevel: 'organization',
            assignLevelValue: r.tenantId,
            assignLevelValueMeaning: r.tenantName,
            _assignLevelValue: r.tenantId,
            _assignLevelValueMeaning: r.tenantName,
            isNew: true,
            // 新加进来的 角色 都是可以管理的
            manageableFlag: 1,
            _status: 'create'
          });
        })), _toConsumableArray(dataSource)),
        pagination: isCreate ? false : addItemsToPagination(roles.length, dataSource.length, pagination),
        visible: false
      });
      return Promise.resolve();
    }
    /**
     * 新增角色模态框取消按钮点击
     */

  }, {
    key: "handleRoleAddCancelBtnClick",
    value: function handleRoleAddCancelBtnClick() {
      this.setState({
        visible: false
      });
    }
    /**
     * 打开新增角色 选择模态框
     */

  }, {
    key: "handleRoleAddBtnClick",
    value: function handleRoleAddBtnClick() {
      // if (isEmpty(noAllocRoles)) {
      //   Modal.warn({
      //     content: intl
      //       .get('ciam.subAccount.view.message.noEnoughRole')
      //       .d('可分配的角色已全部分配完毕'),
      //   });
      //   return;
      // }
      var _this$props3 = this.props,
          isCreate = _this$props3.isCreate,
          _this$props3$initialV = _this$props3.initialValue,
          initialValue = _this$props3$initialV === void 0 ? {} : _this$props3$initialV;
      var _this$state$dataSourc = this.state.dataSource,
          dataSource = _this$state$dataSourc === void 0 ? [] : _this$state$dataSourc;
      var roleModalProps = {
        excludeRoleIds: [],
        excludeUserIds: []
      };

      if (!isCreate) {
        roleModalProps.excludeUserIds.push(initialValue.id);
      }

      dataSource.forEach(function (r) {
        if (r.isNew) {
          roleModalProps.excludeRoleIds.push(r.id);
        }
      });
      this.setState({
        visible: true,
        roleModalProps: roleModalProps
      });
    }
  }, {
    key: "fetchRoles",
    value: function fetchRoles(fields) {
      var fetchAllRoles = this.props.fetchAllRoles;
      return fetchAllRoles(fields);
    }
    /**
     * @param {String[]} selectedRowKeys 选中的rowKey
     */

  }, {
    key: "handleRoleSelectionChange",
    value: function handleRoleSelectionChange(selectedRowKeys) {
      this.setState({
        selectedRowKeys: selectedRowKeys
      });
    }
    /**
     * 删除选中的角色
     * 由于 租户级这边 删除后 是重新查询, 所以 不需要保存之前的 分页信息
     */

  }, {
    key: "handleRoleRemoveBtnClick",
    value: function handleRoleRemoveBtnClick() {
      var _this$props4 = this.props,
          deleteRoles = _this$props4.deleteRoles,
          initialValue = _this$props4.initialValue,
          _this$props4$isCreate = _this$props4.isCreate,
          isCreate = _this$props4$isCreate === void 0 ? true : _this$props4$isCreate;
      var _this$state3 = this.state,
          dataSource = _this$state3.dataSource,
          selectedRowKeys = _this$state3.selectedRowKeys,
          pagination = _this$state3.pagination;
      var that = this;

      if (selectedRowKeys.length === 0) {
        Modal.error({
          content: intl.get('ciam.subAccount.view.message.chooseRoleFirst').d('请先选择要删除的角色')
        });
        return;
      }

      Modal.confirm({
        title: intl.get('cpaas.common.message.confirm.title').d('提示'),
        content: intl.get("ciam.subAccount.view.message.title.content").d('确定删除吗？'),
        onOk: function onOk() {
          var ids = [];
          var newDataSource = [];
          dataSource.forEach(function (item) {
            if (!item.isNew && selectedRowKeys.indexOf(item.id) >= 0) {
              ids.push({
                roleId: item.id,
                memberId: initialValue.id
              });
            }

            if (!(item.isNew && selectedRowKeys.indexOf(item.id) >= 0)) {
              newDataSource.push(item);
            }
          });

          if (ids.length > 0) {
            deleteRoles(ids).then(function () {
              that.setState({
                dataSource: newDataSource,
                selectedRowKeys: [] // pagination: isCreate ? false: delItemsToPagination(selectedRowKeys.length, dataSource.length, pagination),

              });
              that.handleRoleTableChange();
              notification.success();
            });
          } else {
            that.setState({
              dataSource: newDataSource,
              selectedRowKeys: [],
              pagination: isCreate ? false : delItemsToPagination(selectedRowKeys.length, dataSource.length, pagination)
            });
            notification.success();
          }
        }
      });
    }
    /**
     * 默认角色改变
     * @param {object} record 默认角色 改变
     */

  }, {
    key: "handleRoleDefaultChange",
    value: function handleRoleDefaultChange(record) {
      var _this2 = this;

      if (record.defaultRole) {
        // 已经是 默认角色了 什么都不做 则取消默认角色并将该租户加入 删除角色租户中
        this.cancelDefaultParams.add(record.tenantId);
      }

      var defaultChangeTo = !record.defaultRole;
      var _this$state$dataSourc2 = this.state.dataSource,
          dataSource = _this$state$dataSourc2 === void 0 ? [] : _this$state$dataSourc2;
      this.setState({
        dataSource: dataSource.map(function (item) {
          if (item.id === record.id) {
            return _objectSpread(_objectSpread({}, item), {}, {
              defaultRole: defaultChangeTo,
              defaultRoleIdUpdate: true
            });
          }

          if (defaultChangeTo && item.tenantId === record.tenantId) {
            // item 取消同租户的 defaultRoleId
            if (item.defaultRole) {
              _this2.cancelDefaultParams.add(item.tenantId);
            }

            return _objectSpread(_objectSpread({}, item), {}, {
              defaultRole: false,
              defaultRoleIdUpdate: item.defaultRole
            });
          }

          return item;
        })
      });
    }
    /**
     * 角色 table 分页改变
     * 如果是新增用户 分页是
     * @param {?object} page
     * @param {?object} filter
     * @param {?object} sort
     */

  }, {
    key: "handleRoleTableChange",
    value: function handleRoleTableChange(page, _, sort) {
      var _this3 = this;

      var _this$props5 = this.props,
          fetchUserRoles = _this$props5.fetchUserRoles,
          _this$props5$isCreate = _this$props5.isCreate,
          isCreate = _this$props5$isCreate === void 0 ? true : _this$props5$isCreate,
          _this$props5$initialV = _this$props5.initialValue,
          initialValue = _this$props5$initialV === void 0 ? {} : _this$props5$initialV;

      if (!isCreate) {
        this.showRoleTableLoading();
        fetchUserRoles({
          page: page,
          sort: sort,
          userId: initialValue.id
        }).then(function (roleContent) {
          // 在前面中已经 getResponse 了
          if (roleContent) {
            var dataSource = roleContent.content.map(function (r) {
              return _objectSpread(_objectSpread({}, r), {}, {
                _status: 'update'
              });
            }) || [];

            _this3.setState({
              oldDataSource: _cloneDeep(dataSource),
              dataSource: dataSource,
              pagination: createPagination(roleContent)
            }); // 翻页清空 已取消默认角色的租户


            _this3.cancelDefaultParams.clear();
          }
        }).finally(function () {
          _this3.hiddenRoleTableLoading();
        });
      }
    }
  }, {
    key: "showRoleTableLoading",
    value: function showRoleTableLoading() {
      this.setState({
        roleTableFetchLoading: true
      });
    }
  }, {
    key: "hiddenRoleTableLoading",
    value: function hiddenRoleTableLoading() {
      this.setState({
        roleTableFetchLoading: false
      });
    }
  }, {
    key: "changeCountryId",
    value: function changeCountryId() {
      var setFieldsValue = this.props.form.setFieldsValue;
      setFieldsValue({
        regionId: undefined
      });
    }
    /**
     * @date 2019-06-13
     * 区号改变 需要 重置手机号的校验状态
     */

  }, {
    key: "reValidationPhone",
    value: function reValidationPhone(value) {
      var form = this.props.form;
      var prevInternationalTelCode = form.getFieldValue('internationalTelCode');

      if (value === '+86' || prevInternationalTelCode === '+86') {
        // 只要 +86 出现在 中间态 就需要重新手动校验 phone
        var curPhone = form.getFieldValue('phone');
        var errors = null;

        if (curPhone) {
          var testReg = value === '+86' ? PHONE : NOT_CHINA_PHONE;

          if (!testReg.test(curPhone)) {
            errors = [new Error(intl.get('cpaas.common.validation.phone').d('手机格式不正确'))];
          }
        } else {
          errors = [new Error(intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.subAccount.model.user.phone').d('手机号码')
          }))];
        }

        form.setFields({
          phone: {
            value: curPhone,
            errors: errors
          }
        });
      }
    } // #region 验证密码修改后 是否和 确认密码一致

    /**
     * 检查 确认密码是否与密码一致
     */

  }, {
    key: "validatePasswordRepeatForPassword",
    value: function validatePasswordRepeatForPassword(e) {
      var form = this.props.form;
      var anotherPassword = form.getFieldValue('anotherPassword');
      var anotherPasswordField = {
        value: anotherPassword
      };

      if (e.target.value) {
        if (e.target.value === anotherPassword) {
          anotherPasswordField.errors = null;
        } else {
          anotherPasswordField.errors = [new Error(intl.get('ciam.subAccount.view.validation.passwordSame').d('确认密码必须与密码一致'))];
        }
      } else {
        anotherPasswordField.errors = null;
      }

      form.setFields({
        anotherPassword: anotherPasswordField
      });
    } // #regionend

    /**
     * 渲染新增表单
     */

  }, {
    key: "renderCreateForm",
    value: function renderCreateForm() {
      var _this$props6 = this.props,
          form = _this$props6.form,
          _this$props6$password = _this$props6.passwordTipMsg,
          passwordTipMsg = _this$props6$password === void 0 ? {} : _this$props6$password,
          customizeForm = _this$props6.customizeForm;
      var dateFormat = getDateFormat();
      var _this$props7 = this.props,
          _this$props7$idd = _this$props7.idd,
          idd = _this$props7$idd === void 0 ? [] : _this$props7$idd,
          _this$props7$gender = _this$props7.gender,
          gender = _this$props7$gender === void 0 ? [] : _this$props7$gender;
      return customizeForm({
        code: 'CIAM.SUB_ACCOUND.EDIT.FORM_CREATE',
        form: form
      }, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Row, {
        type: "flex"
      }, /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: /*#__PURE__*/React.createElement("span", null, intl.get('ciam.subAccount.model.user.loginName').d('账号'), "\xA0", /*#__PURE__*/React.createElement(Tooltip, {
          title: intl.get('ciam.subAccount.view.message.loginName.tooltip').d('不输入账户则自动生成')
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "question-circle-o"
        })))
      }), form.getFieldDecorator('loginName', {
        rules: [{
          max: 30,
          message: intl.get('cpaas.common.validation.max', {
            max: 30
          })
        }, {
          pattern: CODE,
          message: intl.get('cpaas.common.validation.code').d('大小写及数字，必须以字母、数字开头，可包含“-”、“_”、“.”、“/”')
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.realName').d('名称')
      }), form.getFieldDecorator('realName', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.subAccount.model.user.realName').d('名称')
          })
        }, {
          max: 40,
          message: intl.get('cpaas.common.validation.max', {
            max: 40
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "birthday"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        key: "birthday",
        label: intl.get('ciam.subAccount.model.user.birthday').d('出生日期')
      }), form.getFieldDecorator('birthday', {})( /*#__PURE__*/React.createElement(DatePicker, {
        format: dateFormat,
        style: {
          width: '100%'
        },
        placeholder: ""
      })))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "nickname"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.nickname').d('昵称')
      }), form.getFieldDecorator('nickname', {
        rules: [{
          max: 10,
          message: intl.get('cpaas.common.validation.max', {
            max: 10
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "gender"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('cpaas.common.gender').d('性别')
      }), form.getFieldDecorator('gender', {})( /*#__PURE__*/React.createElement(Select, {
        allowClear: true
      }, _map(gender, function (item) {
        return /*#__PURE__*/React.createElement(Select.Option, {
          value: item.value,
          key: item.value
        }, item.meaning);
      }))))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "country"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.countryId').d('国家')
      }), form.getFieldDecorator('countryId', {})( /*#__PURE__*/React.createElement(Lov, {
        code: "CPFM.COUNTRY",
        onChange: this.changeCountryId,
        queryParams: {
          enabledFlag: 1
        } // textValue={initialValue.countryName}
        // textField="tenantName"
        // disabled={!isCreate}

      })))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "regionId"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.regionId').d('地区')
      }), form.getFieldDecorator('regionId', {})( /*#__PURE__*/React.createElement(Lov, {
        code: "CPFM.REGION",
        queryParams: {
          countryId: form.getFieldValue('countryId')
        } // textValue={initialValue.regionName}
        // textField="tenantName"
        // disabled={!isCreate}

      })))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "addressDetail"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.addressDetail').d('详细地址')
      }), form.getFieldDecorator('addressDetail', {
        rules: [{
          max: 50,
          message: intl.get('cpaas.common.validation.max', {
            max: 50
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.email').d('邮箱')
      }), form.getFieldDecorator('email', {
        rules: [{
          pattern: EMAIL,
          message: intl.get('cpaas.common.validation.email').d('邮箱格式不正确')
        }, {
          max: 128,
          message: intl.get('cpaas.common.validation.max', {
            max: 128
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.phone').d('手机号码')
      }), form.getFieldDecorator('phone', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.subAccount.model.user.phone').d('手机号码')
          })
        }, {
          pattern: form.getFieldValue('internationalTelCode') === '+86' ? PHONE : NOT_CHINA_PHONE,
          message: intl.get('cpaas.common.validation.phone').d('手机格式不正确')
        }]
      })( /*#__PURE__*/React.createElement(Input, {
        addonBefore: form.getFieldDecorator('internationalTelCode', {
          initialValue: idd[0] && idd[0].value || '+86'
        })( /*#__PURE__*/React.createElement(Select, {
          onChange: this.reValidationPhone
        }, _map(idd, function (r) {
          return /*#__PURE__*/React.createElement(Select.Option, {
            key: r.value,
            value: r.value
          }, r.meaning);
        })))
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: /*#__PURE__*/React.createElement("span", null, intl.get('ciam.subAccount.model.user.password').d('密码'), "\xA0", /*#__PURE__*/React.createElement(Tooltip, {
          title: intl.get('ciam.subAccount.view.message.password.tooltip').d('不输入密码则使用默认密码')
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "question-circle-o"
        })))
      }), form.getFieldDecorator('password', {
        rules: [{
          validator: function validator(_, value, callback) {
            validatePasswordRule(value, callback, _objectSpread(_objectSpread({}, passwordTipMsg), {}, {
              loginName: form.getFieldValue('loginName')
            }));
          }
        }]
      })( /*#__PURE__*/React.createElement(Input, {
        type: "password",
        autocomplete: "new-password",
        onChange: this.validatePasswordRepeatForPassword
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('cpaas.common.date.active.from').d('有效日期从')
      }), form.getFieldDecorator('startDateActive', {
        initialValue: undefined,
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('cpaas.common.date.active.from').d('有效日期从')
          })
        }]
      })( /*#__PURE__*/React.createElement(DatePicker, {
        allowClear: false,
        format: dateFormat,
        style: {
          width: '100%'
        },
        placeholder: null,
        disabledDate: function disabledDate(currentDate) {
          return form.getFieldValue('endDateActive') && moment(form.getFieldValue('endDateActive')).isBefore(currentDate, 'day');
        }
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('cpaas.common.date.active.to').d('有效日期至')
      }), form.getFieldDecorator('endDateActive', {
        rules: [{
          type: 'object',
          validator: this.validateEndDateActive
        }]
      })( /*#__PURE__*/React.createElement(DatePicker, {
        format: dateFormat,
        style: {
          width: '100%'
        },
        placeholder: null,
        disabledDate: function disabledDate(currentDate) {
          return form.getFieldValue('startDateActive') && moment(form.getFieldValue('startDateActive')).isAfter(currentDate, 'day');
        }
      })))))));
    }
    /**
     * 渲染编辑表单
     */

  }, {
    key: "renderEditForm",
    value: function renderEditForm() {
      var _this$props8 = this.props,
          form = _this$props8.form,
          _this$props8$initialV = _this$props8.initialValue,
          initialValue = _this$props8$initialV === void 0 ? {} : _this$props8$initialV,
          customizeForm = _this$props8.customizeForm;
      var _this$props9 = this.props,
          _this$props9$idd = _this$props9.idd,
          idd = _this$props9$idd === void 0 ? [] : _this$props9$idd,
          _this$props9$gender = _this$props9.gender,
          gender = _this$props9$gender === void 0 ? [] : _this$props9$gender;
      var emailError = form.getFieldError('email');
      var sameEmail = initialValue.email === form.getFieldValue('email');
      var phoneError = form.getFieldError('phone');
      var samePhone = initialValue.phone === form.getFieldValue('phone');
      var dateFormat = getDateFormat();
      return customizeForm({
        code: 'CIAM.SUB_ACCOUND.EDIT.FORM_EDIT',
        dataSource: initialValue,
        form: form
      }, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: /*#__PURE__*/React.createElement("span", null, intl.get('ciam.subAccount.model.user.loginName').d('账号'), "\xA0", /*#__PURE__*/React.createElement(Tooltip, {
          title: intl.get('ciam.subAccount.view.message.loginName.tooltip').d('不输入账户则自动生成')
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "question-circle-o"
        })))
      }), form.getFieldDecorator('loginName', {
        initialValue: initialValue.loginName,
        rules: [{
          max: 30,
          message: intl.get('cpaas.common.validation.max', {
            max: 30
          })
        } // {
        //   pattern: CODE,
        //   message: intl
        //     .get('cpaas.common.validation.code')
        //     .d('大小写及数字，必须以字母、数字开头，可包含“-”、“_”、“.”、“/”'),
        // },
        ]
      })( /*#__PURE__*/React.createElement(Input, {
        disabled: initialValue.loginName !== undefined
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.realName').d('名称')
      }), form.getFieldDecorator('realName', {
        initialValue: initialValue.realName,
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.subAccount.model.user.realName').d('名称')
          })
        }, {
          max: 40,
          message: intl.get('cpaas.common.validation.max', {
            max: 40
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "birthday"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        key: "birthday",
        label: intl.get('ciam.subAccount.model.user.birthday').d('出生日期')
      }), form.getFieldDecorator('birthday', {
        initialValue: initialValue.birthday ? moment(initialValue.birthday, DEFAULT_DATE_FORMAT) : undefined
      })( /*#__PURE__*/React.createElement(DatePicker, {
        format: dateFormat,
        style: {
          width: '100%'
        },
        placeholder: ""
      })))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "nickname"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.nickname').d('昵称')
      }), form.getFieldDecorator('nickname', {
        initialValue: initialValue.nickname,
        rules: [{
          max: 10,
          message: intl.get('cpaas.common.validation.max', {
            max: 10
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "gender"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('cpaas.common.gender').d('性别')
      }), form.getFieldDecorator('gender', {
        initialValue: _isUndefined(initialValue.gender) ? '' : "".concat(initialValue.gender)
      })( /*#__PURE__*/React.createElement(Select, {
        allowClear: true
      }, _map(gender, function (item) {
        return /*#__PURE__*/React.createElement(Select.Option, {
          value: item.value,
          key: item.value
        }, item.meaning);
      }))))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "country"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.countryId').d('国家')
      }), form.getFieldDecorator('countryId', {
        initialValue: initialValue.countryId
      })( /*#__PURE__*/React.createElement(Lov, {
        code: "CPFM.COUNTRY",
        onChange: this.changeCountryId,
        textValue: initialValue.countryName,
        queryParams: {
          enabledFlag: 1
        } // textField="tenantName"
        // disabled={!isCreate}

      })))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "regionId"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.regionId').d('地区')
      }), form.getFieldDecorator('regionId', {
        initialValue: initialValue.regionId
      })( /*#__PURE__*/React.createElement(Lov, {
        code: "CPFM.REGION",
        queryParams: {
          countryId: form.getFieldValue('countryId')
        },
        textValue: initialValue.regionName // textField="tenantName"
        // disabled={!isCreate}

      })))), /*#__PURE__*/React.createElement(Col, Object.assign({
        key: "addressDetail"
      }, FORM_COL_2_LAYOUT), /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.addressDetail').d('详细地址')
      }), form.getFieldDecorator('addressDetail', {
        initialValue: initialValue.addressDetail,
        rules: [{
          max: 50,
          message: intl.get('cpaas.common.validation.max', {
            max: 50
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        hasFeedback: true,
        help: // eslint-disable-next-line no-nested-ternary
        emailError ? _join(emailError) : sameEmail && initialValue.email && initialValue.emailCheckFlag || !form.getFieldValue('email') ? '' : intl.get('ciam.subAccount.view.validation.emailNotCheck').d('邮箱未验证'),
        validateStatus: // eslint-disable-next-line no-nested-ternary
        emailError ? 'error' : // eslint-disable-next-line no-nested-ternary
        sameEmail && initialValue.email && initialValue.emailCheckFlag ? 'success' : form.getFieldValue('email') ? 'warning' : undefined,
        label: intl.get('ciam.subAccount.model.user.email').d('邮箱')
      }), form.getFieldDecorator('email', {
        initialValue: initialValue.email,
        rules: [{
          pattern: EMAIL,
          message: intl.get('cpaas.common.validation.email').d('邮箱格式不正确')
        }]
      })( /*#__PURE__*/React.createElement(Input, null)))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.phone').d('手机号码'),
        hasFeedback: true,
        help: // eslint-disable-next-line no-nested-ternary
        phoneError ? _join(phoneError) : initialValue.phoneCheckFlag ? '' : intl.get('ciam.subAccount.view.validation.phoneNotCheck').d('手机号码未验证'),
        validateStatus: // eslint-disable-next-line no-nested-ternary
        phoneError ? 'error' : samePhone && initialValue.phoneCheckFlag ? 'success' : 'warning'
      }), form.getFieldDecorator('phone', {
        initialValue: initialValue.phone,
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.subAccount.model.user.phone').d('手机号码')
          })
        }, {
          pattern: form.getFieldValue('internationalTelCode') === '+86' ? PHONE : NOT_CHINA_PHONE,
          message: intl.get('cpaas.common.validation.phone').d('手机格式不正确')
        }]
      })( /*#__PURE__*/React.createElement(Input, {
        addonBefore: form.getFieldDecorator('internationalTelCode', {
          initialValue: initialValue.internationalTelCode || idd[0] && idd[0].value || '+86'
        })( /*#__PURE__*/React.createElement(Select, {
          onChange: this.reValidationPhone
        }, _map(idd, function (r) {
          return /*#__PURE__*/React.createElement(Select.Option, {
            key: r.value,
            value: r.value
          }, r.meaning);
        })))
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('cpaas.common.date.active.from').d('有效日期从')
      }), form.getFieldDecorator('startDateActive', {
        initialValue: initialValue.startDateActive && moment(initialValue.startDateActive),
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.subAccount.model.subAccount.startDateActive').d('有效日期从')
          })
        }]
      })( /*#__PURE__*/React.createElement(DatePicker, {
        allowClear: false,
        format: dateFormat,
        style: {
          width: '100%'
        },
        placeholder: null,
        disabledDate: function disabledDate(currentDate) {
          return form.getFieldValue('endDateActive') && moment(form.getFieldValue('endDateActive')).isBefore(currentDate, 'day');
        }
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('cpaas.common.date.active.to').d('有效日期至')
      }), form.getFieldDecorator('endDateActive', {
        initialValue: initialValue.endDateActive && moment(initialValue.endDateActive)
      })( /*#__PURE__*/React.createElement(DatePicker, {
        format: dateFormat,
        style: {
          width: '100%'
        },
        placeholder: null,
        disabledDate: function disabledDate(currentDate) {
          return form.getFieldValue('startDateActive') && moment(form.getFieldValue('startDateActive')).isAfter(currentDate, 'day');
        }
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_2_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, MODAL_FORM_ITEM_LAYOUT, {
        label: intl.get('ciam.subAccount.model.user.enabled').d('冻结')
      }), form.getFieldDecorator('enabled', {
        initialValue: !!initialValue.enabled
      })( /*#__PURE__*/React.createElement(Switch, {
        checkedValue: false,
        unCheckedValue: true
      })))))));
    }
    /**
     * 渲染表单
     * 根据 isCreate 选择 渲染不同的表单
     * @return
     */

  }, {
    key: "renderForm",
    value: function renderForm() {
      var isCreate = this.props.isCreate;

      if (isCreate) {
        return this.renderCreateForm();
      }

      return this.renderEditForm();
    }
    /**
     * 渲染 分配角色Table
     */

  }, {
    key: "renderRoleTable",
    value: function renderRoleTable() {
      var _this4 = this;

      var _this$state4 = this.state,
          _this$state4$dataSour = _this$state4.dataSource,
          dataSource = _this$state4$dataSour === void 0 ? [] : _this$state4$dataSour,
          _this$state4$selected = _this$state4.selectedRowKeys,
          selectedRowKeys = _this$state4$selected === void 0 ? [] : _this$state4$selected,
          roleTableFetchLoading = _this$state4.roleTableFetchLoading,
          _this$state4$paginati = _this$state4.pagination,
          pagination = _this$state4$paginati === void 0 ? false : _this$state4$paginati;
      var _this$props10 = this.props,
          isAdmin = _this$props10.isAdmin,
          _this$props10$initial = _this$props10.initialValue,
          initialValue = _this$props10$initial === void 0 ? {} : _this$props10$initial,
          isCreate = _this$props10.isCreate;
      var rowSelection = {
        selectedRowKeys: selectedRowKeys,
        onChange: this.handleRoleSelectionChange,
        getCheckboxProps: function getCheckboxProps(record) {
          return {
            disabled: isAdmin && !record.isNew || record.manageableFlag === 0
          };
        }
      };
      var columns = [{
        title: intl.get('ciam.subAccount.model.role.name').d('角色名称'),
        dataIndex: 'name'
      }, !VERSION_IS_OP && {
        title: intl.get('entity.tenant.name').d('租户名称'),
        dataIndex: 'tenantName',
        width: 250
      }, {
        title: intl.get('ciam.subAccount.model.role.startDateActive').d('起始时间'),
        key: 'startDateActive',
        width: 140,
        render: function render(_, record) {
          var $form = record.$form;
          var getFieldDecorator = $form.getFieldDecorator;
          var dateFormat = getDateFormat();
          return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('startDateActive', {
            initialValue: record.startDateActive ? moment(record.startDateActive, DEFAULT_DATE_FORMAT) : undefined
          })( /*#__PURE__*/React.createElement(DatePicker, {
            format: dateFormat,
            style: {
              width: '100%'
            },
            disabled: record.manageableFlag === 0,
            placeholder: null,
            disabledDate: function disabledDate(currentDate) {
              return $form.getFieldValue('endDateActive') && moment($form.getFieldValue('endDateActive')).isBefore(currentDate, 'day');
            }
          })));
        }
      }, {
        title: intl.get('ciam.subAccount.model.role.endDateActive').d('失效时间'),
        key: 'endDateActive',
        width: 140,
        render: function render(_, record) {
          var $form = record.$form;
          var getFieldDecorator = $form.getFieldDecorator;
          var dateFormat = getDateFormat();
          return /*#__PURE__*/React.createElement(Form.Item, null, getFieldDecorator('endDateActive', {
            initialValue: record.endDateActive ? moment(record.endDateActive, DEFAULT_DATE_FORMAT) : undefined
          })( /*#__PURE__*/React.createElement(DatePicker, {
            format: dateFormat,
            style: {
              width: '100%'
            },
            disabled: record.manageableFlag === 0,
            placeholder: null,
            disabledDate: function disabledDate(currentDate) {
              return $form.getFieldValue('startDateActive') && moment($form.getFieldValue('startDateActive')).isAfter(currentDate, 'day');
            }
          })));
        }
      }, {
        title: intl.get('ciam.subAccount.model.role.defaultRoleId').d('默认'),
        key: 'defaultRole',
        width: 60,
        render: function render(_, record) {
          var defaultRole = record.defaultRole,
              assignLevel = record.assignLevel;

          if (assignLevel === 'organization' || assignLevel === 'org') {
            return /*#__PURE__*/React.createElement(Checkbox, {
              checked: defaultRole,
              onClick: function onClick() {
                _this4.handleRoleDefaultChange(record);
              },
              disabled: isCreate ? false : initialValue.userType !== 'P'
            });
          }

          return null;
        }
      }].filter(Boolean);
      return /*#__PURE__*/React.createElement(EditTable, {
        bordered: true,
        rowKey: "id",
        onChange: this.handleRoleTableChange,
        loading: roleTableFetchLoading,
        rowSelection: rowSelection,
        dataSource: dataSource,
        pagination: pagination,
        columns: columns,
        scroll: {
          x: tableScrollWidth(columns)
        }
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this5 = this;

      var _this$state5 = this.state,
          selectedRowKeys = _this$state5.selectedRowKeys,
          visible = _this$state5.visible,
          _this$state5$roleModa = _this$state5.roleModalProps,
          roleModalProps = _this$state5$roleModa === void 0 ? {} : _this$state5$roleModa;
      var _this$props11 = this.props,
          path = _this$props11.path,
          isAdmin = _this$props11.isAdmin,
          isCreate = _this$props11.isCreate,
          _this$props11$initial = _this$props11.initialValue,
          initialValue = _this$props11$initial === void 0 ? {} : _this$props11$initial,
          loadingDistributeUsers = _this$props11.loadingDistributeUsers,
          _this$props11$deleteR = _this$props11.deleteRolesLoading,
          deleteRolesLoading = _this$props11$deleteR === void 0 ? false : _this$props11$deleteR,
          _this$props11$current = _this$props11.currentUser.currentRoleCode,
          currentRoleCode = _this$props11$current === void 0 ? '' : _this$props11$current;
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Form, null, this.renderForm(), // eslint-disable-next-line no-nested-ternary
      currentRoleCode === 'role/organization/default/administrator' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Row, {
        style: {
          textAlign: 'right'
        }
      }, /*#__PURE__*/React.createElement(Col, {
        span: 23
      }, /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.deleteEdit"),
          type: 'button',
          meaning: '子账户管理-删除账号编辑'
        }],
        style: initialValue.userType === 'P' || isCreate ? {
          marginRight: 8
        } : {
          display: 'none'
        },
        onClick: this.handleRoleRemoveBtnClick,
        disabled: selectedRowKeys.length === 0,
        loading: deleteRolesLoading
      }, intl.get('cpaas.common.button.delete').d('删除')), /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.createEdit"),
          type: 'button',
          meaning: '子账户管理-新建账号编辑'
        }],
        type: "primary",
        onClick: function onClick() {
          return _this5.handleRoleAddBtnClick();
        },
        style: initialValue.userType !== 'P' && !isCreate ? {
          display: 'none'
        } : {
          marginRight: 10
        }
      }, intl.get('cpaas.common.button.create').d('新建')))), /*#__PURE__*/React.createElement(Col, {
        span: 1
      })), /*#__PURE__*/React.createElement(Row, {
        type: "flex"
      }, /*#__PURE__*/React.createElement(Col, {
        span: 3
      }), /*#__PURE__*/React.createElement(Col, {
        span: 20,
        className: styles['rule-table']
      }, this.renderRoleTable()))) : isAdmin ? /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, null, /*#__PURE__*/React.createElement(Form.Item, {
        label: intl.get('ciam.subAccount.view.message.title.role').d('角色'),
        labelCol: {
          span: 3
        },
        wrapperCol: {
          span: 20
        },
        className: styles['rule-table']
      }, this.renderRoleTable()))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Row, {
        style: {
          textAlign: 'right'
        }
      }, /*#__PURE__*/React.createElement(Col, {
        span: 23
      }, /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.deleteEdit"),
          type: 'button',
          meaning: '子账户管理-删除账号编辑'
        }],
        style: initialValue.userType === 'P' || isCreate ? {
          marginRight: 8
        } : {
          display: 'none'
        },
        onClick: this.handleRoleRemoveBtnClick,
        disabled: selectedRowKeys.length === 0
      }, intl.get('cpaas.common.button.delete').d('删除')), /*#__PURE__*/React.createElement(ButtonPermission, {
        permissionList: [{
          code: "".concat(path, ".button.createEdit"),
          type: 'button',
          meaning: '子账户管理-新建账号编辑'
        }],
        type: "primary",
        onClick: function onClick() {
          return _this5.handleRoleAddBtnClick();
        },
        style: initialValue.userType !== 'P' && !isCreate ? {
          display: 'none'
        } : {
          marginRight: 10
        }
      }, intl.get('cpaas.common.button.create').d('新建')))), /*#__PURE__*/React.createElement(Col, {
        span: 1
      })), /*#__PURE__*/React.createElement(Row, {
        type: "flex"
      }, /*#__PURE__*/React.createElement(Col, {
        span: 3
      }), /*#__PURE__*/React.createElement(Col, {
        span: 20,
        className: styles['rule-table']
      }, this.renderRoleTable())))), !!visible && /*#__PURE__*/React.createElement(RoleModal, Object.assign({}, roleModalProps, {
        visible: visible,
        loading: loadingDistributeUsers,
        fetchRoles: this.fetchRoles,
        onSave: this.handleRoleAddSaveBtnClick,
        onCancel: this.handleRoleAddCancelBtnClick
      })));
    }
  }], [{
    key: "getDerivedStateFromProps",
    value:
    /**
     * @param {Object} nextProps 下一个属性
     * @param {Object} prevState 上一个状态
     */
    function getDerivedStateFromProps(nextProps, prevState) {
      var nextState = {};
      var level = nextProps.level,
          isCreate = nextProps.isCreate;

      if (isCreate && prevState.pagination !== false) {
        // 新建分页没有 分页
        nextState.pagination = false;
      }

      if (level !== prevState.level) {
        nextState.level = level;
        nextState.levelMap = {};

        _forEach(level, function (l) {
          nextState.levelMap[l.value] = l;
        });
      }

      return nextState;
    }
  }]);

  return EditForm;
}(React.Component), _class3.defaultProps = {
  dataSource: [],
  level: []
}, _class3), (_applyDecoratedDescriptor(_class2.prototype, "validatePasswordRepeat", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "validatePasswordRepeat"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "validateEndDateActive", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "validateEndDateActive"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "getEditFormData", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "getEditFormData"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleRoleAddSaveBtnClick", [_dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "handleRoleAddSaveBtnClick"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleRoleAddCancelBtnClick", [_dec6], Object.getOwnPropertyDescriptor(_class2.prototype, "handleRoleAddCancelBtnClick"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleRoleAddBtnClick", [_dec7], Object.getOwnPropertyDescriptor(_class2.prototype, "handleRoleAddBtnClick"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "fetchRoles", [_dec8], Object.getOwnPropertyDescriptor(_class2.prototype, "fetchRoles"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleRoleSelectionChange", [_dec9], Object.getOwnPropertyDescriptor(_class2.prototype, "handleRoleSelectionChange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleRoleRemoveBtnClick", [_dec10], Object.getOwnPropertyDescriptor(_class2.prototype, "handleRoleRemoveBtnClick"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "handleRoleTableChange", [_dec11], Object.getOwnPropertyDescriptor(_class2.prototype, "handleRoleTableChange"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "showRoleTableLoading", [_dec12], Object.getOwnPropertyDescriptor(_class2.prototype, "showRoleTableLoading"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "hiddenRoleTableLoading", [_dec13], Object.getOwnPropertyDescriptor(_class2.prototype, "hiddenRoleTableLoading"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "changeCountryId", [_dec14], Object.getOwnPropertyDescriptor(_class2.prototype, "changeCountryId"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "reValidationPhone", [_dec15], Object.getOwnPropertyDescriptor(_class2.prototype, "reValidationPhone"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "validatePasswordRepeatForPassword", [_dec16], Object.getOwnPropertyDescriptor(_class2.prototype, "validatePasswordRepeatForPassword"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "renderForm", [_dec17], Object.getOwnPropertyDescriptor(_class2.prototype, "renderForm"), _class2.prototype), _applyDecoratedDescriptor(_class2.prototype, "renderRoleTable", [_dec18], Object.getOwnPropertyDescriptor(_class2.prototype, "renderRoleTable"), _class2.prototype)), _class2)) || _class);
export { EditForm as default };